//
//  pingLunCell.m
//  A Learning Walk
//
//  Created by dllo on 16/6/23.
//  Copyright © 2016年 战斗民族. All rights reserved.
//

#import "pingLunCell.h"

@implementation pingLunCell

-(void)dealloc{
    [_imageT release];
    [_labelN release];
    [_labelT release];
    [_view release];
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatCell];
    }
    return self;
}
-(void)creatCell{
    self.imageT = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"125"]];
    self.imageT.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.imageT];
    self.imageT.layer.borderWidth = 1;
    
    self.labelT = [FengLabel LabelwithFrame:CGRectMake(0, 0, 0, 0) Color:[UIColor clearColor] font:15];
    self.labelT.textColor = [UIColor redColor];
    [self.contentView addSubview:self.labelT];
    
    self.labelN = [FengLabel LabelwithFrame:CGRectMake(0, 0, 0, 0) Color:[UIColor clearColor] font:15];
    [self.contentView addSubview:self.labelN];
    self.labelN.numberOfLines = 0;
    
    self.view = [[UIView alloc] init];
    self.view.backgroundColor = [UIColor grayColor];
    [self.contentView addSubview:self.view];
}
-(void)layoutSubviews{
    [super layoutSubviews];
    
    self.imageT.frame = CGRectMake(10, 10, 30, 30);
    self.labelT.frame = CGRectMake(self.imageT.frame.size.width+self.imageT.frame.origin.x+15, 10, self.contentView.frame.size.width/2, 20);
    
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:15], NSFontAttributeName,nil];
    CGRect rect = [_model.content boundingRectWithSize:CGSizeMake(self.contentView.frame.size.width-80, 0) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    self.labelN.frame = CGRectMake(self.labelT.frame.origin.x, self.labelT.frame.size.height+self.labelT.frame.origin.y+15, self.contentView.frame.size.width-80, rect.size.height);
    
    self.view.frame = CGRectMake(30, self.contentView.frame.size.height-1, self.contentView.frame.size.width-30, 1);
    
}

-(void)setModel:(commentlist *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    [self.imageT sd_setImageWithURL:[NSURL URLWithString:_model.headimg] placeholderImage:[UIImage imageNamed:@"125"]];
    self.labelT.text = _model.username;
    self.labelN.text = _model.content;

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
